import commonjs from '@rollup/plugin-commonjs';
import resolve, { nodeResolve } from '@rollup/plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import vue from 'rollup-plugin-vue';
import postcss from 'rollup-plugin-postcss';
import external from 'rollup-plugin-peer-deps-external';
import babel from "@rollup/plugin-babel";

// @ts-ignore
import autoprefixer from 'autoprefixer';
// @ts-ignore
import pkg from './package.json';

export default {
    input: 'src/index.ts',
    output: [
        {
            file: pkg.main,
            format: 'umd',
            name: pkg.name,
            exports: 'named',
            sourcemap: true,
            globals: {
                "$": "readonly"
            },
        },
        {
            file: pkg.module,
            format: 'es',
            exports: 'named',
            sourcemap: true,
        }
    ],
    plugins: [
        vue({
            preprocessStyles: true
        }),
        postcss({
            extensions: ['.css', '.scss', '.sass'],
            plugins: [autoprefixer()]
        }),
        typescript({
            useTsconfigDeclarationDir: true
        }),
        commonjs(),
        nodeResolve(),
        external(),
        babel({
            presets: ["@vue/babel-preset-jsx"]
        })
    ],
    external: ['element-plus', 'axios']
};